<?php

/**
 * Setting form.
 *
 * @package    berta-s
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class SettingForm extends SettingFormCommons
{
	public function configure(){
		$this->useFields(); // reset - our form will show custom values and model will save them on settings array field

		/* convention over configuration! */
		/* field names represent: group.subgroup and must be sorted in presentation order for groups and subgroups */

		//	renderType:
		//	text, select, onoff (options=[0,1] || [false,true] || [off,on] || [no,yes] ),
		//	number (text with integer field type/validation) - no need to set, if the right validator is used - see settings/indexSuccess.json,
		//	color (select, marked as color renderType, got preselected options and possibility to enter custom value)


		 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
	    ///  TESTS   ////////////////////////////////////////////////////////////////////////////////////////////////

	    /*$this->setWidget(	"test.fontColor",
	    					new sfWidgetFormChoice(
	    						array("label" => "test color", "choices" => array("#000" => "black", "#FF0000" => "red")),
	    						array(
	    							"description" => 'Test color',
	    							"renderType" => "color",
	    							"cssconn"		=> array(0 => array("selector" => "#sideColumn h1", "property" => "color"))
	    						)
	    					)
	    );
		$this->setDefault("test.fontColor", "#000"); // or #000, #000000, rgb(0,0,0), whatever
		$this->setValidator("test.fontColor", new sfValidatorString(array("required" => false)));

		$this->setWidget(	"test.someImage",
	    					new sfWidgetFormInputFile(
	    						array("label" => "Some image file", ),
	    						array("description" => "Upload random image")
	    					)
	    );
	    //$this->setDefault("test.pageBackground", "/favicon.ico");
	    $this->setValidator("test.someImage", new sfValidatorFile(array("required" => false, "path" => sfConfig::get("sf_upload_dir"))));

		$this->setWidget(	"test.fontWeight",
	    					new sfWidgetFormChoice(
	    						array("label" => "Font type", "choices" => array("normal" => "Normal", "bold" => "<strong>Bold</strong>")),
	    						array(
	    							"description" => "",
	    							"cssconn"		=> array(0 => array("selector" => "#sideColumn h1", "property" => "font-weight"))
	    						)
	    					)
	    );
		$this->setDefault("test.fontWeight", "normal");
		$this->setValidator("test.fontWeight", new sfValidatorChoice(array("required" => false, "choices" => array("normal", "bold"))));

		$this->setWidget(	"test.fontStyle",
	    					new sfWidgetFormChoice(
	    						array("label" => "Font type", "choices" => array("normal" => "Normal", "italic" => "<em>Italic</em>")),
	    						array(
	    							"description" => "",
	    							"cssconn"		=> array(0 => array("selector" => "#sideColumn h1", "property" => "font-style"))
	    						)
	    					)
	    );
		$this->setDefault("test.fontStyle", "normal");
		$this->setValidator("test.fontStyle", new sfValidatorChoice(array("required" => false, "choices" => array("normal", "italic"))));


		$this->setWidget(	"test.fontSize",
	    					new sfWidgetFormInputText(
	    						array("label" => "Font size"),
	    						array(
	    							"renderType"	=> "number",
	    							"description" 	=> "Maximum dimensions for images in your site.",
	    							"unit"			=> "px",
	    							"min"			=> 6,
	    							"max"			=> 60,
	    							"cssconn"		=> array(0 => array("selector" => "#sideColumn h1", "property" => "font-size"))
	    						)
	    					)
	    );
		$this->setDefault("test.fontSize", '14px');
		$this->setValidator("test.fontSize", new sfValidatorRegex(array("required" => false, "pattern" => "/^(0|\d+(px|em|%))$/")));

		*/



		 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
	    ///  TEMPLATE   //////////////////////////////////////////////////////////////////////////////////////////////

	    $this->setWidget(	"template.template_id",
	    					new sfWidgetFormDoctrineChoice(
	    						array("model" => "Template", "label" => "Template"),
	    						array(
	    							"description" => "Templates are like skins or themes for your site. You can choose one template from the ones installed in your templates folder. To add a new template to this list, upload it to the templates folder via FTP"
	    						)
	    					)
	    );
        $this->setDefault("template.template_id", 1);
	    $this->setValidator("template.template_id", new sfValidatorDoctrineChoice(array("model" => "Template", "column" => "id", "required" => false)));




	     /////////////////////////////////////////////////////////////////////////////////////////////////////////////
	    ///  TEXTS   ////////////////////////////////////////////////////////////////////////////////////////////////

	    /*$this->setWidget(	"site.ownerName",
	    					new sfWidgetFormInputText(
	    						array("label" => "My name"),
	    						array("description" => "Your name will be put in a meta-tag in the code of your site. You can choose any name ;)")
	    					)
	    );
	    $this->setDefault("site.ownerName", "berta");
	    $this->setValidator("site.ownerName",	new sfValidatorString(array("required" => false)));*/

	    /**
		 * LOGO
		 */
		$this->setWidget("site.logo",
							new sfWidgetFormInputFile(
								array("label" => "Logo"),
								array(
									"description"   => "Image that is your LOGO",
									
									/* TODO: Add "htmlconn" support */
									"htmlconn"	    => array(0 => array("container" => "#xMainHeading", "html" => "<img src=\"%1\" />"))
								)
							)
		);
		$this->setDefault("site.logo", null);
		$this->setValidator("site.logo", new sfValidatorFile(array("required" => false, "path" => sfConfig::get("sf_upload_dir"))));


		/**
		 * Page title that is displayed in the title bar
		 */
	    $this->setWidget(	"site.page_title",
	    					new sfWidgetFormInputText(
	    						array("label" => "Browser's title bar text"),
	    						array("description" => "Text that appears in the browser title bar")
	    					)
	   	);
	   	$this->setDefault("site.page_title", "berta");
	   	$this->setValidator("site.page_title", new sfValidatorString(array("required" => false)));

		/**
		 * META Description
		 */
	    $this->setWidget(	"site.meta_description",
	    					new sfWidgetFormInputText(
	    						array("label" => "<META> description"),
	    						array("description" => "Site description is visible only to search engines. It should not be longer than one or two sentences.")
	    					)
	    );
	   	$this->setDefault("site.meta_description", "Personal portfolio built with Berta");
	   	$this->setValidator("site.meta_description", new sfValidatorString(array("required" => false)));

		/**
		 * META Keywords
		 */
	    $this->setWidget(	"site.meta_keywords",
	    					new sfWidgetFormInputText(
	    						array("label" => "<META> keywords"),
	    						array("description" => "Keywords visible only to search engines. Keywords along with the description can improve your site ranking in search results.")
	    					)
	    );
		$this->setDefault("site.meta_keywords", "berta");
		$this->setValidator("site.meta_keywords", new sfValidatorString(array("required" => false)));

		/**
		 * Favicon
		 */
		$this->setWidget(	"site.favicon",
							new sfWidgetFormInputFile(
								array("label" => "Favicon", ),
								array("description" => "Small picture to display in the address bar of the browser. The file must be in .ICO format and 16x16 pixels big.")
							)
		);
		$this->setDefault("site.favicon", "/favicon.ico");
		$this->setValidator("site.favicon", new sfValidatorFile(array("required" => false, "path" => sfConfig::get("sf_upload_dir"))));


		$this->setWidget("site.google_analytics_id",
							new sfWidgetFormInputText(
								array("label" => "Google Analytics ID"),
								array("description" => 'The ID of the <a href="http://google.com/analytics" target="_blank">Google Analytics</a> site profile. To obtain an ID, register in <a href="http://google.com/analytics" target="_blank">Google Analytics</a> and create a profile for your site.')
							)
		);
		$this->setValidator("site.google_analytics_id", new sfValidatorRegex(array("required" => false, "pattern" => "/(\w{2}-\d+-\d{1,3})/")));




	     /////////////////////////////////////////////////////////////////////////////////////////////////////////////
	    ///  PAGE LAYOUT (???)   ////////////////////////////////////////////////////////////////////////////////////



	    /*$this->setWidget(	"pageLayout.contentWidth",
	    					new sfWidgetFormInputText(
	    						array("label" => "Content width"),
	    						array(
	    							"description" 	=> 	"Content width",
	    							"unit"			=>	"px",
	    							"renderGroup"	=> 	"contentSize",
	    							"renderType" 	=> "number",
	    							"cssconn"		=> array(0 => array("selector" => "#mainColumn", "property" => "width")),
	    						)
	    					)
	    );
		$this->setDefault("pageLayout.contentWidth", "600px");
		$this->setValidator("pageLayout.contentWidth", new sfValidatorRegex(array("required" => false, "pattern" => "/^(0|\d+(px|em|%))$/")));*/

	    # Navigation group
	    /*$this->setWidget(	"navigation.landingSectionVisible",
	    					new sfWidgetFormChoice(
	    						array("label" => "Is first section visible in menu?", "choices" => array(false, true)),
	    						array(
	    							"description" => 'Choose "no" to hide the first section in the main menu. Link from the page title (or header image) will lead to it. NOTE: This setting has no effect, if the section has a submenu; then it is visible at all times.',
									"renderType" => "switch",
	    						)
	    					)
	    );
		$this->setDefault("navigation.landingSectionVisible", 0);
		$this->setValidator("navigation.landingSectionVisible", new sfValidatorBoolean(array("required" => false)));*/


	     /////////////////////////////////////////////////////////////////////////////////////////////////////////////
	    ///  MEDIA   ////////////////////////////////////////////////////////////////////////////////////////////////

	    /*$this->setWidget(	"media.imagesMaxWidth",
	    					new sfWidgetFormInputText(
	    						array("label" => "Max image width"),
							    array(
									"description" 	=> 	"Maximum dimensions for images in your site.",
									"unit"			=>	"px",
									"renderGroup"	=> 	"imageSizes",
									"renderType" 	=> "number"
								)
							)
		);
		$this->setDefault("media.imagesMaxWidth", sfConfig::get("sf_images_max_width"));
		$this->setValidator("media.imagesMaxWidth", new sfValidatorInteger(array("required" => false)));

		$this->setWidget(	"media.imagesMaxHeight",
							new sfWidgetFormInputText(
								array("label" => "Max image height"),
								array(
									"description"	=> "If you will upload larger images, they will be down-sized to fit these maximum bounds.",
									"unit"			=>	"px",
									"renderGroup"	=> 	"imageSizes",
									"renderType" 	=> "number"
								)
							)
		);
		$this->setDefault("media.imagesMaxHeight", sfConfig::get("sf_images_max_height"));
		$this->setValidator("media.imagesMaxHeight", new sfValidatorInteger(array("required" => false)));

	    $this->setWidget(	"media.imagesMinWidth",
	   						new sfWidgetFormInputText(
	    						array("label" => "Min image width"),
	    						array(
	    							"description" 	=> "Minimum dimensions for images in your site.",
	    							"unit"			=>	"px",
	    							"renderGroup"	=> 	"imageSizes",
	    							"renderType" 	=> "number"
	    						)
	   						)
	   	);
		$this->setDefault("media.imagesMinWidth", sfConfig::get("sf_images_min_width"));
		$this->setValidator("media.imagesMinWidth", new sfValidatorInteger(array("required" => false)));

	    $this->setWidget(	"media.imagesMinHeight",
	    					new sfWidgetFormInputText(
	    						array("label" => "Min image height"),
	    						array(
	    							"description" => "You will not be able to upload smaller sized images.",
	    							"unit"			=>	"px",
	    							"renderGroup"	=> 	"imageSizes",
	    							"renderType" 	=> "number"
	    						)
	    					)
	    );
		$this->setDefault("media.imagesMinHeight", sfConfig::get("sf_images_min_height"));
		$this->setValidator("media.imagesMinHeight", new sfValidatorInteger(array("required" => false)));*/




	     /////////////////////////////////////////////////////////////////////////////////////////////////////////////
	    ///  ENTRY LAYOUT   /////////////////////////////////////////////////////////////////////////////////////////

	    /*$this->setWidget(	"entryLayout.galleryVideoPlayer",
	    					new sfWidgetFormChoice(
	    						array("label" => "Video player", "choices" => array("JWPlayer" => "JWPlayer", "NonverBlaster" => "NonverBlaster")),
	    						array("description" => "Choose between the two visually different players for your video files.")
	    					)
	    );
		$this->setDefault("entryLayout.galleryVideoPlayer", "JWPlayer");
		$this->setValidator("entryLayout.galleryVideoPlayer", new sfValidatorChoice(array("required" => false, "choices" => array("JWPlayer", "NonverBlaster"))));


	    $this->setWidget(	"entryLayout.gallerySlideshowAutoRewind",
	    					new sfWidgetFormChoice(
	    						array("label" => "Auto-rewind gallery slideshow", "choices" => array(false, true)),
	    						array(
	    							"description" => "Display the first image after clicking on the last image in galleries that are in slideshow mode.",
	    							"renderType" => "switch",
	    						)
	    					)
	    );
		$this->setDefault("entryLayout.gallerySlideshowAutoRewind", false);
		$this->setValidator("entryLayout.gallerySlideshowAutoRewind", new sfValidatorBoolean(array("required" => false)));*/







	}

	public function generatePageLayoutFaviconFilename($file){
		return "favicon.ico";
	}


}
